<html>
<head>
  <style>
    .box {
      height: 100px;
      width: 100px;
      margin: 10px;
      background-color: blue;
      transition-property: transform;
      transition-duration: 0.2s;
    }
  </style>
  <script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    var numDone = 0;
    function transitionEnded()
    {
      ++numDone;
      if (numDone == 2) {
        if (window.GCController)
          GCController.collect();

        document.getElementById('results').innerHTML = 'Did not crash, so PASSED';

        if (window.testRunner)
          testRunner.notifyDone();
      }
    }

    function startTest()
    {
      var box1 = document.getElementById('box1');
      box1.addEventListener('transitionend', function() {
        box1.parentNode.removeChild(box1);
        transitionEnded();
      }, false);
      box1.style.transform = 'translate(100px, 0)';

      var box2 = document.getElementById('box2');
      box2.addEventListener('transitionend', function() {
        box2.style.display = 'none';
        transitionEnded();
      }, false);
      box2.style.transform = 'translate(100px, 0)';
    }
    
    window.addEventListener('load', startTest, false);
  </script>
</head>
<body>

<p>Tests element removal and hiding in transitionend event handler. Should not crash.</p>

<div id="container">
  <div id="box1" class="box"></div>
  <div id="box2" class="box"></div>
</div>
<div id="results"></div>
</body>
</html>
